Skip to content

Conversation

@jj22ee
Copy link
Contributor

@jj22ee jj22ee commented Jul 25, 2025

Issue #, if available:

  • Currently, ADOT cannot exports metrics in AWS Lambda environment because Lambda freezes the execution environment asap after invocation.
  • The existing EMF Exporter only outputs to CW Logs

Description of changes:

  • Sync AWS Lambda patch to forceFlush metrics after Lambda function invocation.
  • Introduce ConsoleEMFExporter, which exports OTel metrics to standard output using the CloudWatch Embedded Metric Format (EMF). In the Lambda environment, logs written to standard output are automatically forwarded to CloudWatch by Lambda's built-in logging agent, so this is an efficient way to export OTel metrics in Lambda to CW as EMF.

Testing:

START RequestId: fc230af0-020a-429b-8a3d-b7c0a011a777 Version: $LATEST
{"level":50,"time":1753469912921,"pid":2,"hostname":"169.254.67.97","msg":"/histogram endpoint 0"}
2025-07-25T18:58:33.141Z	fc230af0-020a-429b-8a3d-b7c0a011a777	INFO	{"_aws":{"Timestamp":1753469913043,"CloudWatchMetrics":[{"Namespace":"test_adot_namespace2","Metrics":[{"Name":"histogram.counter","Unit":"Milliseconds"}],"Dimensions":[["histogramKey1","histogramKey2"]]}]},"Version":"1","otel.resource.service.name":"adot-lambda-logs-emf-support-testing","otel.resource.telemetry.sdk.language":"nodejs","otel.resource.telemetry.sdk.name":"opentelemetry","otel.resource.telemetry.sdk.version":"1.30.1","otel.resource.telemetry.auto.version":"0.6.0-dev0-aws","otel.resource.cloud.region":"us-west-1","otel.resource.cloud.provider":"aws","otel.resource.faas.name":"adot-lambda-logs-emf-support-testing","otel.resource.faas.version":"$LATEST","otel.resource.faas.instance":"2025/07/25/[$LATEST]990958db5577472a8b72f185f040b136","otel.resource.aws.log.group.names":"/aws/lambda/adot-lambda-logs-emf-support-testing","histogram.counter":{"Values":[2.997969481393705,3.9945921121710146,0],"Counts":[1,2,2],"Count":5,"Sum":11,"Max":4,"Min":0},"histogramKey1":"histogramValue1","histogramKey2":"histogramValue2"}
END RequestId: fc230af0-020a-429b-8a3d-b7c0a011a777
REPORT RequestId: fc230af0-020a-429b-8a3d-b7c0a011a777	Duration: 399.18 ms	Billed Duration: 400 ms	Memory Size: 128 MB	Max Memory Used: 127 MB	Init Duration: 1426.89 ms	
XRAY TraceId: 1-6883d3d7-48a03512232241fa27fe6529	SegmentId: ed5a5f628350482b	Sampled: true	

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@jj22ee jj22ee requested a review from a team as a code owner July 25, 2025 18:55
wangzlei
wangzlei previously approved these changes Jul 25, 2025
@jj22ee jj22ee merged commit 99ed284 into aws-observability:main Jul 29, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants